<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	session.setAttribute("basePath", basePath);
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<base href="${basePath }">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="description" content="">
<meta name="author" content="">
<title>西普茗茶商品-收货地址</title>
<meta name="renderer" content="webkit">

<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="https://cdn.bootcss.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="assets/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css" />
<link href="assets/css/animate.css" rel="stylesheet" type="text/css" />
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN PAGE LEVEL STYLES -->
<link href="https://cdn.bootcss.com/Swiper/3.0.8/css/swiper.min.css" rel="stylesheet" type="text/css" />
<!-- END PAGE LEVEL STYLES -->
<!-- BEGIN THEME STYLES -->
<link href="assets/css/style-metronic.css" rel="stylesheet" type="text/css" />
<link href="assets/css/style.css" rel="stylesheet" type="text/css" />
<link href="assets/css/style-responsive.css" rel="stylesheet" type="text/css" />
<link href="assets/css/plugins.css" rel="stylesheet" type="text/css" />
<link href="assets/css/themes/light.css" rel="stylesheet" type="text/css" id="style_color" />
<link href="assets/css/print.css" rel="stylesheet" type="text/css" media="print" />
<link href="assets/css/custom.css" rel="stylesheet" type="text/css" />
<link href="assets/css/pages/blog.css" rel="stylesheet" type="text/css" />
<link href="css/iconfont.css" rel="stylesheet" type="text/css" />
<!-- END THEME STYLES -->
<link rel="shortcut icon" href="favicon.ico" />

<script type="text/javascript">
	var isHTML5 = true;
</script>
<!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
	<script src="js/excanvas.min.js"></script> 
    <script type="text/javascript">
		isHTML5 = false;
	</script>
<![endif]-->
<style type="text/css">
body {
	background: #fef9f3 !important;
}
</style>
</head>
<!--/head-->
<!-- BEGIN BODY -->
<body class="page-footer-fixed">
	<div class="clearfix "></div>
	<!-- BEGIN CONTAINER -->
	<div class="page-container">

		<!-- BEGIN CONTENT -->
		<div class="page-content-wrapper">
			<div class="page-content no-space" style="margin-bottom: 50px !important;">
				<c:if test="${buyerAddressList==null||fn:length(buyerAddressList)<=0 }">
					<p class="text-center margin-top-20 margin-bottom-20">没有更多地址了</p>
				</c:if>

				<div class="list-group margin-top-20">
					<c:forEach items="${buyerAddressList }" var="ba" varStatus="baStat">
						<a href="javascript:void(0)" class="list-group-item">
							<i class="fa fa-pencil text-gold pull-right margin-top-15 update_address_i" data-id="${ba.buyerAddressId }" style="font-size: 20px;"></i>
							<p>
								<strong class="text-red">${ba.buyerAddressProvince }</strong><strong class="text-red margin-left-5">${ba.buyerAddressCity }</strong><strong class="text-red margin-left-5">${ba.buyerAddressDistrict }</strong><span
									class="margin-left-5">${ba.buyerAddressDetail }</span>
							</p>
							<p>
								<span>${ba.buyerAddressName}</span><span class="margin-left-5">${ba.buyerAddressPhone }</span>
							</p>
						</a>
					</c:forEach>
				</div>

				<!-- END CONTAINER -->
				<div class="text-center">
					<button id="new_buyer_address_button" class="btn center-block text-gold" style="border-radius: 5px !important; display: inline-block; border: 1px solid #cea047; background: transparent !important;">
						<i class="fa fa-plus-circle"></i> 新增收货地址
					</button>
				</div>
			</div>
		</div>
	</div>

	<!-- BEGIN FOOTER -->
	<div class="footer">
		<div class="container">
			<div class="row">
				<div class="col-xs-3 text-center">
					<a href="./" class="icon-btn">
						<!-- <i class="fa fa-home text-gold"></i> -->
						<i style="font-size: 22px;" class="iconfont text-gold icon-qh-logo">&#xe626;</i>
						<div class="text-gold margin-top-2">首页</div>

					</a>
				</div>
				<div class="col-xs-3 text-center">
					<a href="goods_type/get_shop_goods_type" class="icon-btn">
						<!-- <i class="fa fa-list-ul text-gold"></i> -->
						<i style="font-size: 22px;" class="iconfont text-gold con-qh-all-goods">&#xe622;</i>
						<div class="text-gold margin-top-2">类型</div>
					</a>
				</div>
				<div class="col-xs-3 text-center">
					<a href="cart" class="icon-btn">
						<!-- <i class="fa fa-shopping-cart text-gold"></i> -->
						<i style="font-size: 22px;" class="iconfont text-gold icon-qh-cart">&#xe61b;</i>
						<div class="text-gold margin-top-2">购物车</div>

						<span class="badge badge-important" id="shooping_cart_icon_number"></span>
					</a>
				</div>
				<div class="col-xs-3 text-center">
					<a href="item/infocenter.jsp" class="icon-btn">
						<!-- <i class="fa fa-user text-gold"></i> -->
						<i style="font-size: 22px;" class="iconfont text-gold icon-qh-infocenter">&#xe61d;</i>
						<div class="text-gold margin-top-2">个人中心</div>
					</a>
				</div>
			</div>
		</div>
	</div>
	<!-- END FOOTER -->

	<!-- 添加收货地址开始 -->
	<!-- /.modal -->
	<div class="modal fade" id="add_address_modal" tabindex="-1" role="dialog" aria-hidden="true">
		<div class="modal-dialog modal-full" style="margin-left: 0px !important; margin-right: 0px !important;">
			<div class="modal-content">
				<div class="modal-header">
					<h4 class="modal-title text-center">添加收货地址</h4>
				</div>
				<div class="modal-body" style="padding-bottom: 0px !important;">
					<div class="row">
						<div class="col-xs-12">
							<div class="form-group">
								<label for="peopleName">*收货人姓名(2-20字):</label>
								<input type="text" class="form-control" id="peopleName" placeholder="收货人姓名" data-regex="^\S.{0,18}\S$">
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-xs-12">
							<div class="form-group">
								<label for="peopleCellPhone">*收货人手机号:</label>
								<input type="tel" class="form-control" id="peopleCellPhone" placeholder="收货人手机号" data-regex="^\S.{0,48}\S$">
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-xs-12">
							<div class="form-group">
								<label for="peopleAddress">*所在地区:</label>
								<div class="row">
									<div class="col-xs-4">
										<select id="seachprov" class="form-control" name="seachprov" onChange="changeComplexProvince(this.value, sub_array, 'seachcity', 'seachdistrict');"></select>
									</div>
									<div class="col-xs-4">
										<select id="seachcity" name="homecity" class="form-control" onChange="changeCity(this.value,'seachdistrict','seachdistrict');"></select>
									</div>
									<div class="col-xs-4">
										<span id="seachdistrict_div"><select id="seachdistrict" class="form-control" name="seachdistrict"></select></span>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-xs-12">
							<div class="form-group">
								<label for="peopleAddress">*详细地址(4-50字):</label>
								<input type="text" class="form-control" id="peopleAddress" placeholder="详细地址" data-regex="^\S.{2,48}\S$">
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-xs-12">
							<input type="checkbox" name="" id="peopleAddressDefault" class="">
							设为默认地址
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn default pull-left border-radius-5" data-dismiss="modal">关闭</button>
					<button type="button" class="btn blue pull-right border-radius-5" id="add_address_submit_button">提交</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<!-- 添加收货地址结束 -->

	<!-- 修改收货地址开始 -->
	<!-- /.modal -->
	<div class="modal fade" id="update_address_modal" tabindex="-1" role="dialog" aria-hidden="true">
		<div class="modal-dialog modal-full" style="margin-left: 0px !important; margin-right: 0px !important;">
			<div class="modal-content">
				<div class="modal-header">
					<h4 class="modal-title text-center">修改收货地址</h4>
				</div>
				<div class="modal-body" style="padding-bottom: 0px !important;">
					<input type="hidden" id="update_addressId">
					<div class="row">
						<div class="col-xs-12">
							<div class="form-group">
								<label for="update_peopleName">*收货人姓名(2-20字):</label>
								<input type="text" class="form-control" id="update_peopleName" placeholder="收货人姓名" data-regex="^\S.{0,18}\S$">
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-xs-12">
							<div class="form-group">
								<label for="update_peopleCellPhone">*收货人手机号:</label>
								<input type="tel" class="form-control" id="update_peopleCellPhone" placeholder="收货人手机号" data-regex="^\S.{0,48}\S$">
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-xs-12">
							<div class="form-group">
								<label for="peopleAddress">*所在地区(不可修改):</label>
								<div class="row">
									<div class="col-xs-12">
										<input id="update_peopleArea" class="form-control text-red" readonly="readonly">
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-xs-12">
							<div class="form-group">
								<label for="update_peopleAddress">*详细地址(4-50字):</label>
								<input type="text" class="form-control" id="update_peopleAddress" placeholder="详细地址" data-regex="^\S.{2,48}\S$">
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-xs-12">
							<input type="checkbox" name="" id="update_peopleAddressDefault" class="">
							设为默认地址
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn default pull-left border-radius-5" data-dismiss="modal">关闭</button>
					<button type="button" class="btn blue pull-right border-radius-5" id="update_address_submit_button">提交</button>
					<button type="button" class="btn red pull-left border-radius-5 margin-left-10" id="delete_address_submit_button">删除</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<!-- 修改收货地址结束 -->

	<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
	<!-- BEGIN CORE PLUGINS -->
	<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
	<script src="https://cdn.bootcss.com/jquery-migrate/1.2.1/jquery-migrate.min.js" type="text/javascript"></script>
	<!-- IMPORTANT! Load jquery-ui-1.10.3.custom.min.js before bootstrap.min.js to fix bootstrap tooltip conflict with jquery ui tooltip -->
	<script src="assets/plugins/jquery-ui/jquery-ui-1.10.3.custom.min.js" type="text/javascript"></script>
	<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" type="text/javascript"></script>
	<script src="assets/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
	<script src="assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
	<script src="assets/plugins/jquery.blockui.min.js" type="text/javascript"></script>
	<script src="assets/plugins/jquery.cokie.min.js" type="text/javascript"></script>
	<script src="assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
	<script src="js/wow.min.js"></script>
	<script src="js/bootstrap.file-input.js"></script>
	<!-- END CORE PLUGINS -->
	<!-- BEGIN PAGE LEVEL PLUGINS -->
	<script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.0.8/js/swiper.jquery.min.js"></script>
	<script type="text/javascript" src="assets/plugins/jquery-validation/dist/jquery.validate.min.js"></script>
	<script type="text/javascript" src="assets/plugins/jquery-validation/localization/messages_zh.js"></script>
	<script type="text/javascript" src="assets/plugins/select2/select2.min.js"></script>
	<script type="text/javascript" src="assets/plugins/jquery-bootpag/jquery.bootpag.min.js"></script>
	<script type="text/javascript" src="js/jquery.form.js"></script>
	<!-- END PAGE LEVEL PLUGINS -->
	<!-- BEGIN PAGE LEVEL SCRIPTS -->
	<script src="js/app.js"></script>
	<script src="js/AreaData_min.js"></script>
	<!-- END PAGE LEVEL SCRIPTS -->

	<script>
		function initComplexArea(a, k, h, p, q, d, b, l)
		{
			var f = initComplexArea.arguments;
			var m = document.getElementById(a);
			var o = document.getElementById(k);
			var n = document.getElementById(h);
			var e = 0;
			var c = 0;
			if (p != undefined)
			{
				if (d != undefined)
				{
					d = parseInt(d);
				}
				else
				{
					d = 0;
				}
				if (b != undefined)
				{
					b = parseInt(b);
				}
				else
				{
					b = 0;
				}
				if (l != undefined)
				{
					l = parseInt(l);
				}
				else
				{
					l = 0
				}
				n[0] = new Option("请选择 ", 0);
				for (e = 0; e < p.length; e++)
				{
					if (p[e] == undefined)
					{
						continue;
					}
					if (f[6])
					{
						if (f[6] == true)
						{
							if (e == 0)
							{
								continue
							}
						}
					}
					m[c] = new Option(p[e], e);
					if (d == e)
					{
						m[c].selected = true;
					}
					c++
				}
				if (q[d] != undefined)
				{
					c = 0;
					for (e = 0; e < q[d].length; e++)
					{
						if (q[d][e] == undefined)
						{
							continue
						}
						if (f[6])
						{
							if ((f[6] == true) && (d != 71) && (d != 81) && (d != 82))
							{
								if ((e % 100) == 0)
								{
									continue
								}
							}
						}
						o[c] = new Option(q[d][e], e);
						if (b == e)
						{
							o[c].selected = true
						}
						c++
					}
				}
			}
		}
		function changeComplexProvince(f, k, e, d)
		{
			var c = changeComplexProvince.arguments;
			var h = document.getElementById(e);
			var g = document.getElementById(d);
			var b = 0;
			var a = 0;
			removeOptions(h);
			f = parseInt(f);
			if (k[f] != undefined)
			{
				for (b = 0; b < k[f].length; b++)
				{
					if (k[f][b] == undefined)
					{
						continue
					}
					if (c[3])
					{
						if ((c[3] == true) && (f != 71) && (f != 81) && (f != 82))
						{
							if ((b % 100) == 0)
							{
								continue
							}
						}
					}
					h[a] = new Option(k[f][b], b);
					a++
				}
			}
			removeOptions(g);
			g[0] = new Option("请选择 ", 0);
			if (f == 71 || f == 81 || f == 82)
			{
				if ($("#" + d + "_div"))
				{
					$("#" + d + "_div").hide();
				}
			}
			else
			{
				if ($("#" + d + "_div"))
				{
					$("#" + d + "_div").show();
				}
			}
		}

		function changeCity(c, a, t)
		{
			$("#" + a).html('<option value="0" >请选择</option>');
			$("#" + a).unbind("change");
			c = parseInt(c);
			var _d = sub_arr[c];
			var str = "";
			str += "<option value='0' >请选择</option>";
			for (var i = c * 100; i < _d.length; i++)
			{
				if (_d[i] == undefined)
					continue;
				str += "<option value='" + i + "' >" + _d[i] + "</option>";
			}
			$("#" + a).html(str);

		}

		function removeOptions(c)
		{
			if ((c != undefined) && (c.options != undefined))
			{
				var a = c.options.length;
				for (var b = 0; b < a; b++)
				{
					c.options[0] = null;
				}
			}
		}

		//得到地区码
		function getAreaID()
		{
			var area = 0;
			if ($("#seachdistrict").val() != "0")
			{
				area = $("#seachdistrict").val();
			}
			else if ($("#seachcity").val() != "0")
			{
				area = $("#seachcity").val();
			}
			else
			{
				area = $("#seachprov").val();
			}
			return area;
		}

		function showAreaID()
		{
			//地区码
			var areaID = getAreaID() == null ? "" : getAreaID();
			//地区名
			var areaName = getAreaNamebyID(areaID);
			alert("您选择的地区码：" + areaID + "      地区名：" + areaName);
		}

		//根据地区码查询地区名
		function getAreaNamebyID(areaID)
		{
			var areaName = "";
			if (areaID.length == 2)
			{
				areaName = area_array[areaID];
			}
			else if (areaID.length == 4)
			{
				var index1 = areaID.substring(0, 2);
				areaName = area_array[index1] + "," + sub_array[index1][areaID];
			}
			else if (areaID.length == 6)
			{
				var index1 = areaID.substring(0, 2);
				var index2 = areaID.substring(0, 4);
				areaName = area_array[index1] + "," + sub_array[index1][index2] + "," + sub_arr[index2][areaID];
			}
			return areaName;
		}

		$(function()
		{
			// Initiat WOW JS
			if (isHTML5 == true)
			{
				new WOW().init();
			}
			App.init();
			$("#new_buyer_address_button").click(function()
			{
				$("#add_address_modal").modal('show');
				initComplexArea('seachprov', 'seachcity', 'seachdistrict', area_array, sub_array, '44', '0', '0');

			});

			$("#add_address_submit_button").click(function()
			{
				var peopleName = $("#peopleName").val();
				var peopleCellPhone = $("#peopleCellPhone").val();
				var peopleAddress = $("#peopleAddress").val();
				var addressDefault;

				//地区码
				var areaID = getAreaID() == null ? "" : getAreaID();
				//地区名
				var areaName = getAreaNamebyID(areaID);

				var areaNameArray = new Array(); //定义一数组 
				areaNameArray = areaName.split(","); //字符分割
				if (areaNameArray.length <= 1)
				{
					alert("所在地区为必选项");
					return false;
				}

				if ($("#peopleAddressDefault").is(':checked'))
				{
					addressDefault = true;
				}
				else
				{
					addressDefault = false;
				}

				if (peopleName.length <= 0 || peopleCellPhone.length <= 0 || peopleAddress.length <= 0)
				{
					alert("标有*的输入项都是必填项.")
					return false;
				}

				var tips = "";
				var tips_number = 1;
				$.each([ $("#peopleName"), $("#peopleCellPhone"), $("#peopleAddress") ], function(i, n)
				{
					if (new RegExp(n.attr("data-regex")).test(n.val()) == false)
					{
						tips += tips_number++ + " . \"" + n.val() + "\" 不满足输入要求;\n";
					}
				});
				if (tips.length > 0)
				{
					alert(tips + "\n请检查一下重新输入.");
					return false;
				}

				var add_address_submit_button_html = $("#add_address_submit_button").html();
				$.ajax(
				{
					url : "${basePath}u_add_new_address_do",
					type : "POST",
					dataType : "json",
					beforeSend : function(XMLHttpRequest)
					{
						$("#add_address_submit_button").attr("disabled", "disabled");
						$("#add_address_submit_button").html("正在提交收货地址中...");
					},
					data :
					{
						'buyerAddress.buyerAddressName' : peopleName,
						'buyerAddress.buyerAddressDetail' : peopleAddress,
						'buyerAddress.buyerAddressPhone' : peopleCellPhone,
						'buyerAddress.buyerAddressProvince' : areaNameArray[0],
						'buyerAddress.buyerAddressCity' : areaNameArray[1],
						'buyerAddress.buyerAddressDistrict' : areaNameArray[2],
						"addressDefault" : addressDefault
					},
					success : function(json, textStatus)
					{
						if (json.success == true)
						{
							alert("添加收货地址成功");
							window.location.href = "show_buyer_address_list?time=" + new Date();
						}
						else
						{
							alert(json.info);
						}
					},
					error : function(XMLHttpRequest, textStatus, errorThrown)
					{
						alert("提交失败，请仔细检查您的输入是否满足要求。");
					},
					complete : function(XMLHttpRequest, textStatus)
					{
						$("#add_address_submit_button").removeAttr("disabled");
						$("#add_address_submit_button").html(add_address_submit_button_html);
					}
				});
			});

			$(".update_address_i").each(function()
			{
				var obj = $(this);
				obj.click(function()
				{
					$.post('${basePath}u_get_address_info_do',
					{
						'id' : obj.attr("data-id")
					},
					//回调函数 
					function(json)
					{
						if (json.success == true)
						{
							$("#update_addressId").val(json.address.buyerAddressId);
							$("#update_peopleName").val(json.address.buyerAddressName);
							$("#update_peopleCellPhone").val(json.address.buyerAddressPhone);
							$("#update_peopleAddress").val(json.address.buyerAddressDetail);
							$("#update_peopleArea").val(json.address.buyerAddressProvince + " " + json.address.buyerAddressCity + " " + json.address.buyerAddressDistrict);
							if (json.address.buyerAddressDefault == "1")
							{
								$("#update_peopleAddressDefault").attr("checked", "checked");
								$.uniform.update();
							}
							$("#update_address_modal").modal('show');
						}
						else
						{
							alert(json.info);
						}
					},
					//返回类型
					"json");
				});
			});

			$("#update_address_submit_button").click(function()
			{
				var update_addressId = $("#update_addressId").val();
				var update_peopleName = $("#update_peopleName").val();
				var update_peopleCellPhone = $("#update_peopleCellPhone").val();
				var update_peopleAddress = $("#update_peopleAddress").val();
				var addressDefault;
				if ($("#update_peopleAddressDefault").is(':checked'))
				{
					addressDefault = true;
				}
				else
				{
					addressDefault = false;
				}

				if (update_addressId.length <= 0 || update_peopleName.length <= 0 || update_peopleCellPhone.length <= 0 || update_peopleAddress.length <= 0)
				{
					alert("标有*的输入项都是必填项.")
					return false;
				}

				var tips = "";
				var tips_number = 1;
				$.each([ $("#update_peopleName"), $("#update_peopleCellPhone"), $("#update_peopleAddress") ], function(i, n)
				{
					if (new RegExp(n.attr("data-regex")).test(n.val()) == false)
					{
						tips += tips_number++ + " . \"" + n.val() + "\" 不满足输入要求;\n";
					}
				});
				if (tips.length > 0)
				{
					alert(tips + "\n请检查一下重新输入.");
					return false;
				}

				var update_address_submit_button_html = $("#update_address_submit_button").html();
				$.ajax(
				{
					url : "${basePath}u_update_address_do",
					type : "POST",
					dataType : "json",
					beforeSend : function(XMLHttpRequest)
					{
						$("#update_address_submit_button").attr("disabled", "disabled");
						$("#update_address_submit_button").html("正在提交收货地址中...");
					},
					data :
					{
						'buyerAddress.buyerAddressId' : update_addressId,
						'buyerAddress.buyerAddressName' : update_peopleName,
						'buyerAddress.buyerAddressDetail' : update_peopleAddress,
						'buyerAddress.buyerAddressPhone' : update_peopleCellPhone,
						"addressDefault" : addressDefault
					},
					success : function(json, textStatus)
					{
						if (json.success == true)
						{
							alert("修改收货地址成功");
							window.location.href = "show_buyer_address_list?time=" + new Date();
						}
						else
						{
							alert(json.info);
						}
					},
					error : function(XMLHttpRequest, textStatus, errorThrown)
					{
						alert("提交失败，请仔细检查您的输入是否满足要求。");
					},
					complete : function(XMLHttpRequest, textStatus)
					{
						$("#update_address_submit_button").removeAttr("disabled");
						$("#update_address_submit_button").html(update_address_submit_button_html);
					}
				});
			});

			$("#delete_address_submit_button").click(function()
			{

				if (confirm("确定删除此收货地址吗?") == false)
				{
					return false;
				}

				var update_addressId = $("#update_addressId").val();

				if (update_addressId.length <= 0)
				{
					alert("id是必需项.")
					return false;
				}

				var delete_address_submit_button_html = $("#delete_address_submit_button").html();
				$.ajax(
				{
					url : "${basePath}u_delete_address_do",
					type : "POST",
					dataType : "json",
					beforeSend : function(XMLHttpRequest)
					{
						$("#delete_address_submit_button").attr("disabled", "disabled");
						$("#delete_address_submit_button").html("正在删除收货地址中...");
					},
					data :
					{
						'buyerAddress.buyerAddressId' : update_addressId
					},
					success : function(json, textStatus)
					{
						if (json.success == true)
						{
							alert("删除收货地址成功");
							window.location.href = "show_buyer_address_list?time=" + new Date();
						}
						else
						{
							alert(json.info);
						}
					},
					error : function(XMLHttpRequest, textStatus, errorThrown)
					{
						alert("提交失败，请仔细检查您的输入是否满足要求。");
					},
					complete : function(XMLHttpRequest, textStatus)
					{
						$("#delete_address_submit_button").removeAttr("disabled");
						$("#delete_address_submit_button").html(delete_address_submit_button_html);
					}
				});
			});

		});
	</script>
	<!-- END JAVASCRIPTS -->
</body>
</html>